# competition
from collections import deque
from random import randint

num = randint(1, 4)
host = deque()
guest = deque()

for i in range(num):
    host.append(randint(1, 100))
    guest.append(randint(1, 100))

print(f"host: {host}, guest: {guest}, num: {num}")

conflict = []
for i in range(randint(0, (num ** 2))):
    v = host[randint(0, num-1)]
    s = guest[randint(0, num-1)]
    conflict.append([v, s])

print(f"conflict: {conflict}")

found = []


def vs(v, s):
    if v in found or s in found:
        return 0

    for l in conflict:
        if v in l and s in l:
            return 0
    return 1


def pair():
    paired = 0
    for v in host:
        for s in guest:
            if vs(v, s):
                found.append(v)
                found.append(s)
                print(f"{v} -> {s}")
                paired += 1
                break
    if paired == num:
        return 1
    return 0


limit = num
count = 0

while count < limit:
    count += 1
    if pair():
        break
    host.rotate(1)
    del found[:]
    print("try again:")
